module WWW
  class Ali
    class Taobao
      class Express<WWW::Ali::Util::Api
        attr_reader :fields,:buyer_nick,:seller_confirm,:receiver_name,:start_created,:end_created,:item_title,:freight_payer,:type,:status,:page_no,:page_size

        def initialize(request,session)
          super(request,session)
          @fields=request[:fields]
          @buyer_nick=request[:buyer_nick]
          @seller_confirm=request[:seller_confirm]
          @receiver_name=request[:receiver_name]
          @start_created=request[:start_created]
          @end_created=request[:end_created]
          @item_title=request[:item_title]
          @freight_payer=request[:freight_payer]
          @type=request[:type]
          @status=request[:status]
          @page_no=request[:page_no]
          @page_size=request[:page_size]

        end
        #搜索当前会话用户做为买家达成的交易记录
        def get_send_items
          params = get_send_items_params
          return WWW::Ali::Util::Tool::get_result params
        end
        def get_send_items_params
          ret_val = get_params
          ##系统级别参数
          ret_val['sip_apiname']="taobao.shippings.send.get"
          ##应用级别参数
          ret_val['fields']=@fields
          ret_val['buyer_nick']=@buyer_nick unless @buyer_nick==nil
          ret_val['seller_confirm']=@seller_confirm unless @seller_confirm==nil
          ret_val['receiver_name']=@receiver_name unless @receiver_name==nil

          ret_val['start_created']=@start_created unless @start_created==nil
          ret_val['end_created']=@end_created unless @end_created==nil
          ret_val['item_title']=@item_title unless @item_title==nil
          ret_val['freight_payer']=@freight_payer unless @freight_payer==nil
          ret_val['type']=@type unless @type==nil
          ret_val['status']=@status unless @status==nil
          ret_val['page_no']=@page_no unless @page_no==nil
          ret_val['page_size']=@page_size unless @page_size==nil

          ret_val['format']='xml'
          ret_val['v']=1.0

          ##计算获得签名信息
          ret_val['sip_sign']=WWW::Ali::Util::Tool::get_sip_sign ret_val

          return ret_val
        end
        #搜索当前会话用户做为卖家达成的交易记录
        def get_sell_items
          params = get_sell_items_params
          return WWW::Ali::Util::Tool::get_result params
        end
        def get_sell_items_params
          ret_val = get_params
          ##系统级别参数
          ret_val['sip_apiname']="taobao.trades.sold.get"
          ##应用级别参数
          ret_val['fields']=@fields

          ret_val['start_created']=@start_created unless @start_created==nil
          ret_val['page_no']=@page_no unless @page_no==nil
          ret_val['page_size']=@page_size unless @page_size==nil

          ret_val['title']=@title unless @title==nil
          ret_val['status']=@status unless @status==nil
          ret_val['end_created']=@end_created unless @end_created==nil

          ret_val['format']='xml'
          ret_val['v']=1.0

          ##计算获得签名信息
          ret_val['sip_sign']=WWW::Ali::Util::Tool::get_sip_sign ret_val

          return ret_val
        end
      end
    end
  end
end
